package com.hundun.tt_pay.pay.controller;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.alipay.api.response.AlipayTradePagePayResponse;
import com.hundun.config.AlipayConfig;

public class alipay {

    public static void main(String[] args) throws AlipayApiException {

        /**
         * 获取配置文件的信息
         */
        String app_id = AlipayConfig.app_id;
        String private_key = AlipayConfig.private_key;
        String notify_url = AlipayConfig.notify_url;
        String return_url = AlipayConfig.return_url;
        String url = AlipayConfig.url;
        String charset = AlipayConfig.charset;
        String format = AlipayConfig.format;
        String public_key = AlipayConfig.public_key;
        String signtype = AlipayConfig.signtype;

        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",
                AlipayConfig.app_id, AlipayConfig.private_key, "json", "GBK", AlipayConfig.public_key, "RSA2");

        //设置请求参数
        AlipayTradePagePayRequest request  = new AlipayTradePagePayRequest();
        request.setBizContent("{\"out_trade_no\":\""+ 11 +"\","
                + "\"total_amount\":\""+ 11 +"\","
                + "\"subject\":\""+ 11 +"\","
                + "\"body\":\""+ 11 +"\","
                + "\"timeout_express\":\"10m\","
                + "\"product_code\":\"FAST_INSTANT_TRADE_PAY\"}");
        AlipayTradePagePayResponse response = alipayClient.sdkExecute(request);
        if(response.isSuccess()){
            System.out.println("调用成功");
        } else {
            System.out.println("调用失败");
        }


    }


}
